#!/bin/bash

# 检测是否已启动
pid=`ps -ef | grep -n 军神网盘 | grep -v grep | grep -v launch | grep -v .sh | awk '{print $2}'`
if [ -n "${pid}" ]
then
   echo "已运行在 pid：${pid}，无需重复启动！"
   exit 0
fi

# 获取当前脚本所在路径
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
军神网盘_DIR=$(dirname "$DIR")

# 启动 军神网盘
nohup $军神网盘_DIR/军神网盘/军神网盘 --spring.config.location=$军神网盘_DIR/application.properties --spring.web.resources.static-locations=file:$军神网盘_DIR/static/  >/dev/null 2>&1 &
echo '启动中...'
sleep 3s

# 输出 pid
pid=`ps -ef | grep -n 军神网盘 | grep -v grep | grep -v .sh | awk '{print $2}'`
echo "目前 PID 为: ${pid}"
